package leetcode.code295;

import leetcode.IDebug;

public abstract class Solution295 implements IDebug {

//    public MedianFinder() {
//
//    }

	abstract public void addNum(int num);

	abstract public double findMedian();

	@Override
	public void debug1() {
		addNum(1);
		System.out.println(" add " + 1);
		addNum(2);
		System.out.println(" add " + 2);
		double res = findMedian();
		System.out.println(" -> 1.5" + " -> " + res + " " + (res == 1.5));
		addNum(3);
		System.out.println(" add " + 3);
		res = findMedian();
		System.out.println(" -> 2" + " -> " + res + " " + (res == 2));
		addNum(4);
		System.out.println(" add " + 4);
		res = findMedian();
		System.out.println(" -> 2.5" + " -> " + res + " " + (res == 2.5));
		int add = 5;
		addNum(add);
		System.out.println(" add " + add);
		res = findMedian();
		System.out.println(" -> 3" + " -> " + res + " " + (res == 3));
	}

	@Override
	public void debug2() {
		test(-1,-1);
		test(-2,-1.5);
		test(-3,-2);
		test(-4,-2.5);
		test(-5,-3);
	}

	private void test(int add, double out) {
		addNum(add);
		double res = findMedian();
		System.out.println(" add " + add);
		System.out.println(" -> " + out + " -> " + res + " " + (res == out));
	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

}
